Repository navigation
Conversation
Fixes #541. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the change to preserve exact UTF-16 string-enum values.
No open issues 🎉
What changed in this PR
Fixes #541 in the core TypeScript validator so serialized string-enum values preserve exact UTF-16 code units, including lone surrogates and BOMs, without changing compiler dependencies or widening validation.
Changes:
- Retrieves enum literal type text through compiler APIs using collision-free, scope-local probes, then restores the original schema.
- Adds 45 offline regressions covering Unicode values, enum variants, containers, diagnostics, and repair.
- Documents exact string matching and Unicode escapes for lone surrogates in schema source.
| File | Description |
|---|---|
| typescript/test/validate.test.ts | Adds exact-value and rejection regressions for Unicode enums and related validation behavior. |
| typescript/src/ts/validate.ts | Replaces lossy enum-value extraction with compiler-formatted literal type text. |
| site/src/docs/typescript/basic-usage.md | Explains UTF-16 matching and escaped schema literals. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #541.
Summary
This is a core-only fix, separate from #538. No compiler dependency changes, decoder patches, schema code execution, diagnostic suppression, string normalization, or validation widening.
Verification
Using Node 24.22.1 and TypeScript 7.0.2:
npm run buildpassed.tsc -p testpassed.git diff --checkpassed.The full
npm test, example builds, and site build were not run.Existing compiler limitation
Raw lone-surrogate characters in schema source still require Unicode escapes; this PR does not patch the compiler transport. The issue's escaped-schema reproduction and serialized values preserve their exact code units.
Related upstream evidence by Marc Rousavy (@mrousavy): microsoft/TypeScript#65458.
Scope follows the approved G2/G5 goals.